package main

import (
	"context"
	"git.900sui.cn/kc/kcgin"
	"git.900sui.cn/kc/kcgin/logs"
	"git.900sui.cn/kc/rabbitmq"
	"github.com/streadway/amqp"
	"strconv"
	userEs "git.900sui.cn/kc/rpcinterface/client/elastic/user"
)


func main() {
	logs.Info("Environment Variable:MSF_ENV:", kcgin.KcConfig.RunMode)
	err := rabbitmq.Rabbitmq.Consume(kcgin.AppConfig.String("queue.setUserInfoToEs"), func(msg amqp.Delivery) {
		uid, err := strconv.Atoi(string(msg.Body))
		if err != nil {
			return
		}
		rpcUserEs := new(userEs.Member).Init()
		defer rpcUserEs.Close()
		reply := false
		// 通过消息队列将用户信息  添加/更新到ES
		if err := rpcUserEs.SetMember(context.Background(), &uid, &reply); err != nil {
			logs.Error("SetAdminBus error: %#v\n",err.Error())
			return
		}
		return
	})
	if err != nil {
		panic(err)
	}
}
